''' <summary>
''' Example class, implementing change notification, to use in examples demonstrating WPFGlue features.
''' </summary>
''' <remarks></remarks>
Public Class Customer
    Implements System.ComponentModel.INotifyPropertyChanged


    Private Shared _Count As Integer = 0
    Private _Index As Integer
    Public Sub New()
        MyBase.New()
        _Count += 1
        _Index = _Count
        Debug.Print("{0} {1} Constructed", Me.GetType.Name, _Index)
    End Sub
    Protected Overrides Sub Finalize()
        Debug.Print("{0} {1} Finalized", Me.GetType.Name, _Index)
        MyBase.Finalize()
    End Sub


    Protected Overridable Sub OnPropertyChanged(ByVal ParamArray propertynames() As String)
        If propertynames.Length = 0 Then
            RaiseEvent PropertyChanged(Me, New System.ComponentModel.PropertyChangedEventArgs(""))
        Else

            For Each propertyName As String In propertynames
                RaiseEvent PropertyChanged(Me, New System.ComponentModel.PropertyChangedEventArgs(propertyName))
            Next
        End If
    End Sub

    Public Event PropertyChanged(ByVal sender As Object, ByVal e As System.ComponentModel.PropertyChangedEventArgs) Implements System.ComponentModel.INotifyPropertyChanged.PropertyChanged

    Private _Name As String
    Private _Address As String
    Private _City As String
    Private _Country As String

    Public Property Name() As String
        Get
            Return _Name
        End Get
        Set(ByVal value As String)
            _Name = value
            OnPropertyChanged("Name")
        End Set
    End Property

    Public Property Address() As String
        Get
            Return _Address
        End Get
        Set(ByVal value As String)
            _Address = value
            OnPropertyChanged("Address")
        End Set
    End Property
    Public Property City() As String
        Get
            Return _City
        End Get
        Set(ByVal value As String)
            _City = value
            OnPropertyChanged("City")
        End Set
    End Property
    Public Property Country() As String
        Get
            Return _Country
        End Get
        Set(ByVal value As String)
            _Country = value
            OnPropertyChanged("Country")
        End Set
    End Property

    Private _Orders As New OrderCollection
    Public ReadOnly Property Orders() As OrderCollection
        Get
            Return _Orders
        End Get
    End Property

    Private Shared _Example As CustomerCollection
    Public Shared ReadOnly Property Example() As CustomerCollection
        Get
            If _Example Is Nothing Then
                _Example = New CustomerCollection
                Dim a As Customer = New Customer() With {.Name = "Alfred B. Mueller", .Address = "1234 Windmill Drive", .City = "72035 Bloomington", .Country = "Tomania"}
                a.Orders.Add(New Order() With {.OrderDate = #1/5/2009#, .Status = OrderStatus.Ordered, .Description = "1 inflatable washing machine", .Value = 1500, .Currency = "EUR"})
                a.Orders.Add(New Order() With {.OrderDate = #1/1/1988#, .Status = OrderStatus.Returned, .Description = "1 young weavil", .Value = 22.5, .Currency = "USD"})
                _Example.Add(a)
                Dim b As Customer = New Customer() With {.Name = "Betty Han", .Address = "The Clockworks", .City = "Andover", .Country = "UK"}
                b.Orders.Add(New Order() With {.OrderDate = #11/13/2009#, .Status = OrderStatus.Paid, .Description = "250kg soy bean sprouts", .Value = 250, .Currency = "GBP"})
                _Example.Add(b)
                Dim c As Customer = New Customer() With {.Name = "Charles N. Ewbie", .Address = "1756 42nd Street", .City = "New York", .Country = "USA"}
                _Example.Add(c)
            End If
            Return _Example
        End Get
    End Property

    Public Overrides Function ToString() As String
        If String.IsNullOrEmpty(_Name) Then
            Return "[New Customer]"
        Else
            Return _Name
        End If
    End Function
End Class

''' <summary>
''' Example class, collection of Customer
''' </summary>
''' <remarks></remarks>
Public Class CustomerCollection
    Inherits System.Collections.ObjectModel.ObservableCollection(Of Customer)
End Class

''' <summary>
''' Example Enum
''' </summary>
''' <remarks></remarks>
Public Enum OrderStatus As Integer
    None
    Ordered
    Shipped
    Returned
    Paid
End Enum

''' <summary>
''' Example class
''' </summary>
''' <remarks></remarks>
Public Class Order
    Implements System.ComponentModel.INotifyPropertyChanged

    Protected Overridable Sub OnPropertyChanged(ByVal ParamArray propertynames() As String)
        If propertynames.Length = 0 Then
            RaiseEvent PropertyChanged(Me, New System.ComponentModel.PropertyChangedEventArgs(""))
        Else

            For Each propertyName As String In propertynames
                RaiseEvent PropertyChanged(Me, New System.ComponentModel.PropertyChangedEventArgs(propertyName))
            Next
        End If
    End Sub

    Public Event PropertyChanged(ByVal sender As Object, ByVal e As System.ComponentModel.PropertyChangedEventArgs) Implements System.ComponentModel.INotifyPropertyChanged.PropertyChanged

    Private _OrderDate As Nullable(Of Date)
    Private _ShipDate As Nullable(Of Date)
    Private _PaymentDate As Nullable(Of Date)
    Private _Status As OrderStatus = OrderStatus.None
    Private _Description As String
    Private _Value As Double = 0
    Private _Currency As String = "USD"

    Public Property OrderDate() As Nullable(Of Date)
        Get
            Return _OrderDate
        End Get
        Set(ByVal value As Nullable(Of Date))
            _OrderDate = value
            OnPropertyChanged("OrderDate")
        End Set
    End Property
    Public Property ShipDate() As Nullable(Of Date)
        Get
            Return _ShipDate
        End Get
        Set(ByVal value As Nullable(Of Date))
            _ShipDate = value
            OnPropertyChanged("ShipDate")
        End Set
    End Property
    Public Property PaymentDate() As Nullable(Of Date)
        Get
            Return _PaymentDate
        End Get
        Set(ByVal value As Nullable(Of Date))
            _PaymentDate = value
            OnPropertyChanged("PaymentDate")
        End Set
    End Property

    Public Property Status() As OrderStatus
        Get
            Return _Status
        End Get
        Set(ByVal value As OrderStatus)
            _Status = value
            OnPropertyChanged("Status")
        End Set
    End Property

    Public Property Value() As Double
        Get
            Return _Value
        End Get
        Set(ByVal value As Double)
            _Value = value
            OnPropertyChanged("Value")
        End Set
    End Property

    Public Property Description() As String
        Get
            Return _Description
        End Get
        Set(ByVal value As String)
            _Description = value
            OnPropertyChanged("Description")
        End Set
    End Property

    Public Property Currency() As String
        Get
            Return _Currency
        End Get
        Set(ByVal value As String)
            _Currency = value
            OnPropertyChanged("Currency")
        End Set
    End Property
End Class

''' <summary>
''' Example class, collection of Order.
''' </summary>
''' <remarks></remarks>
Public Class OrderCollection
    Inherits System.Collections.ObjectModel.ObservableCollection(Of Order)
End Class